package com.kgc.service;

import com.kgc.bean.GoodsItemVo;
import com.kgc.bean.OrderInfo;
import com.kgc.bean.User;

import java.text.ParseException;

/**
 * @Author：周申宇 <p>
 * @Date:2021/6/19 15:57
 * <p>
 * @Decription: 抢购业务的接口
 */
public interface BuyLimitService {

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description:  初始化商品到redis
     */
    boolean initProdStockToRedis(String prodId);

    /**
     * @Author: zhouyu
     * @Param:
     * @Return:
     * @Description: 判断用户是否登录
     */
    boolean checkUserActivity(Integer userId,Integer activityId);

    /**
     * @Author: zhouyu
     * @Param: [activityId]
     * @Return: boolean
     * @Description: 判断是否错过抢购日期
     */
    boolean checkActivityDate(Integer activityId) throws ParseException;

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description: 锁定抢购用户
     */
    boolean lockBuyUser(String userId, String prodId);

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description: 校验商品库存
     */
    boolean checkProdStock(String prodId, Integer buyCount);

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description:  校验库存是否锁定
     */
    boolean isStock(String prodId);

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description: 将订单号存入reids
     */
    void setTradeOrderNoToRedis(String tradeOrderNo, String userId);

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description:
     */
    void createTradeOrder(User user, GoodsItemVo goodsItemVo, Integer buyCount,String tradeOrderNo);

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description: 删除订单号
     */
    boolean deleteOrderNoByOrderNo(String tradeOrderNo);

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description: 减少商品库存
     */
    void subProStockNum(String prodId, Integer buyCount);

    /**
     * @Auther: 周申宇
     * <p>
     * @Date: 2021/6/19
     * <p>
     * @Description: 解锁
     */
    void unLockProStockLock(String prodId);

    /**
     * @Author: zhouyu
     * @Param:
     * @Return:
     * @Description: 根据订单编号查询订单
     */
    OrderInfo queryOrderInfoByOrderInfoId(String orderInfoId);


}


